{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 神经网络"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "神经网络\n",
    "\n",
    "神经网络可以通过 torch.nn 包来构建。\n",
    "\n",
    "现在对于自动梯度(autograd)有一些了解，神经网络是基于自动梯度 (autograd)来定义一些模型。一个 nn.Module 包括层和一个方法 forward(input) 它会返回输出(output)。\n",
    "\n",
    "例如，看一下数字图片识别的网络："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![mnist](./img/mnist.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这是一个简单的前馈神经网络，它接收输入，让输入一个接着一个的通过一些层，最后给出输出。\n",
    "\n",
    "一个典型的神经网络训练过程包括以下几点：\n",
    "\n",
    "1.定义一个包含可训练参数的神经网络\n",
    "\n",
    "2.迭代整个输入(用数据进行训练)\n",
    "\n",
    "3.通过神经网络处理输入\n",
    "\n",
    "4.计算损失(loss)\n",
    "\n",
    "5.反向传播梯度到神经网络的参数\n",
    "\n",
    "6.更新网络的参数，典型的用一个简单的更新方法：weight = weight - learning_rate *gradient"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![梯度更新](\\img\\image-20211118155107151.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\alpha$是学习率(下降步长)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
